<?php
//error_reporting(E_ALL);
//ini_set('memory_limit','256M');

require_once(dirname(__FILE__).'/../../config/ProjectConfiguration.class.php');
//$time = time();
//echo "start: ".date("Y-m-d H:i:s")."\n";
// symfony init
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'cron', FALSE);
//$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', 'dev', TRUE);
sfContext::createInstance($configuration);

//echo "symfony init: done\n";

$site_id = (isset($argv[1]) && $argv[1] ? $argv[1] : null);

CronJobs::parseSite($site_id);

if(!$site_id && (time() - $time < 60))
{
  CronJobs::parseSite();
}

//echo "done: ".(time() - $time)."sec.\n";
